#import "YYText.h"
#import "dfhgwhruebvhrheyluggagerecorder.h"
#import "dfhgwhruebvhrheygarbageequator.h"
#import "dfhgwhruebvhrheybangorganismViewController.h"
#import "dfhgwhruebvhrheyengineeringroyal.h"
#import "dfhgwhruebvhrheysuspicioussenator.h"
#import "dfhgwhruebvhrheyvetobulletinViewController.h"
@interface dfhgwhruebvhrheyvetobulletinViewController ()
@property (weak, nonatomic) IBOutlet UILabel *amountTextLabel;
@property (weak, nonatomic) IBOutlet UIImageView *barCodePhoto;
@property (weak, nonatomic) IBOutlet UILabel *channelTextLabel;
@property (weak, nonatomic) IBOutlet YYLabel *tipsTextLabel;
@property (weak, nonatomic) IBOutlet YYLabel *barCodeTipsTextLabel;
@property (weak, nonatomic) IBOutlet UILabel *nameText;
@end
@implementation dfhgwhruebvhrheyvetobulletinViewController
- (void)viewDidLoad {
    [super viewDidLoad];
	[self loadUI];
}
- (void)loadUI {
	self.amountTextLabel.text = self.amountString;
	[self.channelTextLabel drawBoardWithCornerRadius:20 andColor:primary_color.dhgfywegwygeydwlearneddesignate];
	NSMutableAttributedString *barCodeTipsAttribute = [[NSMutableAttributedString alloc] initWithString:@"1. Barcode can be used at any of the 7-Eleven stores for your payment\n2. Please show this to the cashier for payment\n3. Barcode is vaild for 24 hours"];
	NSMutableParagraphStyle *style1 = [[NSMutableParagraphStyle alloc] init];
	style1.lineSpacing = 5;
	[barCodeTipsAttribute addAttributes:@{
		NSParagraphStyleAttributeName: style1,
		NSFontAttributeName: [UIFont regular:13],
		NSForegroundColorAttributeName: @"#AAAAAA".dhgfywegwygeydwlearneddesignate
	} range:NSMakeRange(0, barCodeTipsAttribute.length)];
	self.barCodeTipsTextLabel.numberOfLines = 0;
	self.barCodeTipsTextLabel.attributedText = barCodeTipsAttribute;
	NSMutableAttributedString *tipsAttribute = [[NSMutableAttributedString alloc] initWithString:@"PAYMENT INSTRUCTIONS:\n1. Go to any partner store within the payment deadline.With the above Contract Number, you can repayment in mainstream channels: GCash, PayMaya, 7-Eleven, Ecpay, RDPawnshop, M Lhuillier.\n2. Tell the cashier that you will be making cash payment, provide the code or Contract Number.\n3. Before paying, verify that the data matches that of this payment receipt.\n4. Keep your proof of payment for any clarification.\n5. We do not accept unofficial repayment channels. In order to prevent fraud, please do not listen to other people changing the repayment channel. If there is any loss, you must bear it yourself. If you have any questions, please contact customer service."];
	NSMutableParagraphStyle *style2 = [[NSMutableParagraphStyle alloc] init];
	style2.lineSpacing = 5;
	[tipsAttribute addAttributes:@{
		NSParagraphStyleAttributeName: style2,
		NSFontAttributeName: [UIFont regular:13],
		NSForegroundColorAttributeName: [UIColor whiteColor]
	} range:NSMakeRange(0, tipsAttribute.length)];
	self.tipsTextLabel.numberOfLines = 0;
	self.tipsTextLabel.attributedText = tipsAttribute;
}
- (void)bindData:(dfhgwhruebvhrheysuspicioussenator *)model {
	if(model.photo.length == 0) return;
	NSData *data = [[NSData alloc] initWithBase64EncodedString:model.photo options:NSUTF8StringEncoding];
	self.barCodePhoto.image = [UIImage imageWithData:data];
}
- (void)bindCodeData:(dfhgwhruebvhrheyengineeringroyal *)code {
	self.nameText.text = code.account_name;
}
- (void)getRepaymentBarCode:(void(^)(void))result {
	NSMutableDictionary *params = [NSMutableDictionary dictionary];
	params[@"g_id"] = self.repayment.ad_id;
	params[@"type"] = @(self.type);
	if(self.type == 1) {
		params[@"c_id"] = self.coupon_id;
	}
	__weak typeof(self) weakSelf = self;
	[[dfhgwhruebvhrheyluggagerecorder shareInstance] dhgfywegwygeydwbarrierawait:dhgfywegwygeydwawaitlamb path:repaymentBarCodeApi isEncrypt:YES withParams:params success:^(NSURLSessionDataTask * _Nonnull task, NSString * _Nonnull json) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		dfhgwhruebvhrheysuspicioussenator *model = [dfhgwhruebvhrheysuspicioussenator yy_modelWithJSON:json];
		if (model.code == 200) {
			[strongSelf bindData:model];
		}else {
			[dfhgwhruebvhrheyoptionsaving.keyWindow show:model.error];
		}
		if (result) {
			result();
		}
	} failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
		if (result) {
			result();
		}
	}];
}
- (IBAction)serviceAction:(UITapGestureRecognizer *)sender {
	dfhgwhruebvhrheybangorganismViewController *webVC = [[dfhgwhruebvhrheybangorganismViewController alloc] init];
	webVC.isShowBottomView = NO;
	[webVC loadURLString:serviceH5];
	webVC.hidesBottomBarWhenPushed = YES;
	webVC.navigationItem.title = @"Assistance";
	[self.navigationController pushViewController:webVC animated:YES];
}
@end
